<template>
  <div style="width: 100%;height: 100%;">
    <div class="con" ref="chartReport"></div>
  </div>
</template>

<script>
import {getAction} from "@/api/manage";
import request from "@/utils/request";


export default {
  name: "EventDeptCountPage",
  components: {},
  data() {
    return {}
  },
  mounted() {
    this.getReportCount();
  },
  created() {

  },
  methods: {


    getReportCount() {
      let that = this;
      let params = {};
        var data = [
        {
          value: 10,
          type: "1",
          name: "一级"
        },
        {
          value: 20,
          type: "2",
          name: "二级"
        },
        {
          value: 30,
          type: "3",
          name: "三级"
        },
        {
          value: 40,
          type: "4",
        }
      ]
      var label = ["一级", "二级", "三级", "四级"];
      that.chartReport(data, label)
      // getAction('/statistic/event/deptReportCount', params).then(response => {
      //   let list = response.rows;
      //   if(response!=null && list!=null){
      //     let data = new Array();
      //     let label = new Array();
      //     for (let i=0;i<list.length;i++){
      //       if(list[i].deptId != "1"){
      //         data.push(list[i].reportCount+list[i].peopleCount)
      //         label.push(list[i].deptName)
      //       }
      //     }
      //     that.chartReport(data, label)
      //   }
      // });
    },


    chartReport(data, label){
      let that = this;
      let charts = that.$echarts.init(this.$refs.chartReport,'');
      let option = {
        color:["#22A4F8","#1BC78B","#F93F00","#FFE400"],
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        grid:{
          top: '5%',
          left: '8%',
          right: '5%',
          // bottom:'10%'
        },
        xAxis: {
          type: 'category',
          data: label,
          axisLabel : {
            interval: 0,//横轴信息全部显示
            rotate: 45,//旋转45度显示
            textStyle: {
              color: '#FFFFFF'
            }
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#fff'
          }
        },
        series: [
          {
            data: data,//[120, 200, 150, 80, 70, 110, 130],
            type: 'bar',
            label: {
              show: true,
              position: 'top'
            },
          }
        ]
      };
      charts.setOption(option);
      // 监听 window 窗口大小变化的事件
      window.onresize = function () {
        // 调用 echarts 实例对象的 resize 方法
        charts.resize()
      }
    },


  }
}
</script>
<style scoped lang="scss">

</style>
